<template>
    <div >
        <el-upload
            :limit="1"
            :file-list="fileList"
            :beforeUpload="beforeUpload"
            action=""
        >
            <el-button size="small" type="warning">点击上传</el-button>
        </el-upload>
        <vue-office-docx :src="src"/>
        <!-- <vue-office-excel :src="src"/> -->
        <vue-office-pdf :src="src"/>
    </div>
</template>

<script>
import VueOfficeDocx from '@vue-office/docx'
import VueOfficePdf from '@vue-office/pdf'
import VueOfficeExcel from '@vue-office/excel'
import '@vue-office/docx/lib/index.css' 
// import '@vue-office/excel/lib/index.css'

export default {
    components: {
        VueOfficeDocx,VueOfficePdf,VueOfficeExcel
    },
    data() {
        return {
            src: '',
            fileList: []
        }
    },
    methods: {
        //在beforeUpload中读取文件内容
        beforeUpload(file) {
            let reader = new FileReader();
            reader.readAsArrayBuffer(file);
            reader.onload = (loadEvent) => {
                let arrayBuffer = loadEvent.target.result;
                this.src = arrayBuffer
            };
            return false
        }
    }
}
</script>